<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>组织管理</title>
    <!-- 公共CSS,JS文件 -->
    <#include "../../admin/common/header.ftl"/>
</head>
<body>
<div class="container-fluid">
    <!-- 左右侧导航 -->
    <div class="row">
        <div class="panel">
            <div class="panel-heading">
                <ol class="breadcrumb" style="margin-bottom: 2px;">
                    <li>首页</li>
                    <li>系统管理</li>
                    <li>组织管理</li>
                    <div style="float: right; padding-bottom: 5px;"><a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="icon icon-refresh"></i></a></div>
                </ol>
            </div>
            <!-- 右侧-左侧导航 -->
            <div class="col-xs-2">
                <div class="col-sm-5">
                    <ul id="organizationTree" class="ztree"></ul>
                </div>
            </div>
            <!-- 右侧-右侧导航 -->
            <div class="col-xs-10">
                <!-- 添加mdal -->
                <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h4 class="modal-title">新增用户</h4>
                            </div>
                            <div class="modal-body">
                                <!-- The form is placed inside the body of modal -->
                                <form id="addForm" action="/admin/user/save" method="post" class="form-horizontal">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">用户名</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" name="userName" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">密码</label>
                                        <div class="col-sm-5">
                                            <input type="password" class="form-control" name="passWord" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">手机号</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" name="phone" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">邮箱</label>
                                        <div class="col-sm-5">
                                            <input type="email" class="form-control" name="email" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">所属角色</label>
                                        <div class="col-sm-5">
                                            <select id="roleList" name="roleList" class="form-control chosen-select" multiple></select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-5 col-sm-offset-3">
                                            <button type="submit" class="btn btn-primary">保存</button>
                                            <button id="resetBtn" type="button" class="btn btn-primary">取消</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 修改modal -->
                <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h4 class="modal-title">修改用户</h4>
                            </div>
                            <div class="modal-body">
                                <!-- The form is placed inside the body of modal -->
                                <form id="editForm" action="/admin/user/edit" method="post" class="form-horizontal">
                                    <input type="hidden" class="form-control" id="id" name="id" value="" />
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">用户名</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="userName" name="userName" value="" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">手机号</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="phone" name="phone" value="" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">邮箱</label>
                                        <div class="col-sm-5">
                                            <input type="email" class="form-control" id="email" name="email" value="" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">所属角色</label>
                                        <div class="col-sm-5">
                                            <select id="editRoleList" name="editRoleList" class="form-control chosen-select" multiple></select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-5 col-sm-offset-3">
                                            <button type="submit" class="btn btn-primary">修改</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <#--内容-->
                <div class="panel-body">
                    <div class="row">
                        <!-- 搜索框 -->
                        <#--<form action="/admin/user/list" method="post">
                            <div class="col-xs-3">
                                <input type="text" id="searchParam" name="searchParam" value="${userName!}" class="form-control" placeholder="用户名、手机号、邮箱">
                            </div>
                            <div class="col-xs-2">
                                <input type="text" name="startDate" value="${startDate!}" class="form-control form-date" placeholder="开始时间" readonly="readonly">
                            </div>
                            <div class="col-xs-2">
                                <input type="text" name="endDate" value="${endDate!}" class="form-control form-date" placeholder="结束时间" readonly="readonly">
                            </div>
                            <div class="col-xs-2">
                                <button class="btn btn-primary" type="submit">搜索</button>
                            </div>
                        </form>-->
                    </div>
                    <div id="toolbar" class="toolbox btn-group" style="padding-top:10px; padding-bottom:10px;">
                        <div class="tools-group">
                            <#--<@shiro.hasPermission name="admin:user:add">-->
                                <button class="btn btn-primary" data-toggle="modal" data-target="#addModal"><i class="icon icon-plus"></i>添加</button>
                            <#--</@shiro.hasPermission>
                            <@shiro.hasPermission name="admin:user:edit">-->
                                <button class="btn btn-success" onclick="optUpdate()"><i class="icon icon-edit"></i> 修改</button>
                            <#--</@shiro.hasPermission>
                            <@shiro.hasPermission name="admin:user:delete">-->
                                <button class="btn btn-danger" onclick="optDelete()"><i class="icon icon-times"></i> 删除</button>
                            <#--</@shiro.hasPermission>-->
                        </div>
                    </div>
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th><input type="checkbox" onclick="checkBox('ids',this.checked)"/></th>
                            <th>序号</th>
                            <th>归属机构</th>
                            <th>机构名称</th>
                            <th>创建时间</th>
                            <th>修改时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#if page.list??>
                            <#list page.list as orgDto>
                                <tr>
                                    <th><input type="checkbox" class="checked_detect" value="${orgDto.id!?c }" name="ids"/></th>
                                    <th>${orgDto_index+1!}</th>
                                    <th>${orgDto.name!}</th>
                                    <th>${orgDto.name!}</th>
                                    <th>${orgDto.tsInsert!}</th>
                                    <th>${orgDto.tsUpdate!}</th>
                                    <th>
                                        <#--<@shiro.hasPermission name="admin:user:edit">-->
                                            <a href="#" onclick="editNode('${orgDto.id!?c }')"><i class="icon icon-edit"></i></a>
                                        <#--</@shiro.hasPermission>
                                        <@shiro.hasPermission name="admin:user:delete">-->
                                            <a href="#" onclick="deleteNode('${orgDto.id!?c }')"><i class="icon icon-trash"></i></a>
                                        <#--</@shiro.hasPermission>-->
                                    </th>
                                </tr>
                            </#list>
                        </#if>
                        </tbody>
                    </table>
                    <!-- 分页 start -->
                    <#include "../../admin/common/page.ftl"/>
                    <!-- 分页 end -->
                </div>
            </div>
        </div>
    </div>
<#include "../../admin/common/footer.ftl"/>
</div>
<script>
    $(function () {
        // 加载菜单树
        $.bootstrapLoading.start();
        $.ajax({
            type : "GET",
            cache : true,
            url : "/admin/organization/tree",
            contentType: "application/json;charset=utf-8",
            dataType:"json",
            success : function (result) {
                if (result.errorCode == 'y') {
                    // 初始化加载菜单树，并且默认全部展开节点
                    var setting = {
                        check: {
                            enable: true
                        },
                        data: {
                            simpleData: {
                                enable: true
                            },
                            // 设置 zTree 显示节点时，将 treeNode 的 menuIcon 属性当做节点图标
                            key: {
                                icon: "menuIcon"
                            }
                        },
                        callback : {
                            onClick : function(event, treeId, treeNode) {
                                location.href = "/admin/organization/list?parentId="+treeNode.id;
                            }
                        }
                    };
                    var zNodes = result.organizationTree;
                    $(document).ready(function(){
                        var ztree = $.fn.zTree.init($("#organizationTree"), setting, zNodes);
                        var nodes = ztree.getNodes();
                        for (var i = 0; i < nodes.length; i++) {
                            ztree.expandNode(nodes[i], true, false, false);//默认展开第一级节点
                        }
                    });
                } else {
                    new $.zui.Messager('提示消息：' + result.errorText, {
                        icon: 'exclamation-sign',
                        type: 'danger',
                        time: 2000
                    }).show();
                }
            },error:function(){
                new $.zui.Messager('提示消息：' + "系统异常", {
                    icon: 'exclamation-sign',
                    type: 'danger',
                    time: 2000
                }).show();
            },complete : function () {
                $.bootstrapLoading.end();
            }
        });
    });
</script>
<#--导入userList.js文件-->
<script src="/static/zui/js/organization/organizationList.js"></script>
</body>
</html>